// Kamikaze.cpp //
#include "Kamikaze.h"
#include "Player.h"
//enemy type that attacks enemy directly

Kamikaze::Kamikaze(string keyname) : Enemy(keyname) // constructor
{
	pointValue = KamikazePointValue;
	health = KamikazeHealth;
	speed = KamikazeIdleSpeed;
	idleDelay = KamikazeIdleDelay;
	foundTarget = false;
}

void Kamikaze::Update(float deltaTime)
{
	if(this->numValue == -1) // kill if it was made divisable
		this->TakeDamage(this->health);

	if(!foundTarget) // hasn't started attack
	{
		idleDelay -= deltaTime; // wait set amount of time
		
		if(idleDelay < 0) // choose who to attack
		{
			// currently moot, always chooses one player
			GameObject* target = PickRandomObject(&PlayerShip::PlayerShipList);
			//creates vector pointed right at target that doesnt change
			direction = target->position - position;
			speed = KamikazeAttackSpeed;
			foundTarget = true;
		}
	}

	Enemy::Update(deltaTime);
}

//special render, shows num on texture, colored appropriately
void Kamikaze::Render(SDL_Surface* screen)
{
	char buffer[4];
	sprintf(buffer, "%d", this->numValue);
	sprite->Render(screen,position);
	sprite->texture->DrawText(screen,buffer,20,this->position.X,this->position.Y,0,0,0,true);
}

